'use strict';
const db = uniCloud.database();
const memoCollection = db.collection('memo');

exports.main = async (event, context) => {
  try {
    // 从 event 中获取要删除备忘录的 _id
    const { id } = event;
    // 根据 _id 删除备忘录
    const res = await memoCollection.doc(id).remove();
    return {
      code: 200,
      message: '删除备忘录成功',
      data: res
    };
  } catch (error) {
    return {
      code: 500,
      message: '删除备忘录失败',
      error: error.message
    };
  }
};